<?php

/**
 * This file is part of project alg-performance.
 *
 * Author: Jake
 * Create: 2019-04-30 17:29:55
 */

namespace App\Services;

use App\Helper\SingletonAble;
use App\Models\User;
use Illuminate\Support\Facades\Auth;

class AppUser
{
    use SingletonAble;

    /** @var AppUser */
    private $ajxUser;

    public function __construct()
    {
        $this->ajxUser = $this->guard()->user();
    }

    /**
     * @return int
     */
    public function getUserId()
    {
        return $this->ajxUser->user_id;
    }

    public function getUserName()
    {
        return $this->ajxUser->user_name;
    }

    /**
     * @return string
     */
    public function getCellphone()
    {
        return $this->ajxUser->cellphone;
    }

    public function guard()
    {
        return Auth::guard('api');
    }
}

